<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:74:"D:\Apache24\htdocs\chenxiangyu/application/link\view\admin\link\index.html";i:1488166136;s:72:"D:\Apache24\htdocs\chenxiangyu/application/ebcms\view\common\header.html";i:1488098063;s:72:"D:\Apache24\htdocs\chenxiangyu/application/ebcms\view\common\footer.html";i:1482201112;}*/ ?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <title>后台管理系统</title>
    <script type="text/javascript" src="__ROOT__/system/js/jquery.min.js"></script>
    <!-- Bootstrap -->
    <link href="__ROOT__/third/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- HTML5 Shim and Respond.js IE8 flowers of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]]
    <script src="http://static.ebcms.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="http://static.ebcms.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="__ROOT__/third/bootstrap/js/bootstrap.min.js"></script>
    <!-- artDialog -->
    <script type="text/javascript" src="__ROOT__/third/artDialog/jquery.artDialog.js"></script>
    <link rel="stylesheet" type="text/css" href="__ROOT__/third/artDialog/skins/default.css">
    <script type="text/javascript" src="__ROOT__/third/artDialog/artDialog.ext.js"></script>
    <!-- 引入后台样式表 -->
    <link rel="stylesheet" type="text/css" href="__ROOT__/system/css/admin.css">
    <script type="text/javascript" src="__ROOT__/system/js/admin.js"></script>
    <script>
        $(function() {

            // 动作绑定
            $('.ebcms-do').bind('click', function(event) {
                var $this  = $(this);
                if ($this.attr('confirm')) {
                    EBCMS.MSG.confirm($this.attr('confirm'),function(){
                        EBCMS.CORE.do({
                            method:$this.attr('method'),
                            url:$this.attr('url'),
                            data:$this.data()
                        });
                    });
                }else{
                    EBCMS.CORE.do({
                        method:$this.attr('method'),
                        url:$this.attr('url'),
                        data:$this.data()
                    });
                }
            });
            $('.ebcms-go').bind('click', function(event) {
                var $this  = $(this);
                if ($this.attr('confirm')) {
                    EBCMS.MSG.confirm($this.attr('confirm'),function(){
                        location.href=$this.attr('url');
                    });
                }else{
                    location.href=$this.attr('url');
                }
            });
            $('.ebcms-change').each(function(index, el) {
                $(this).data('value',$(this).val());
            });
            $('.ebcms-refresh').bind('click', function(event) {
                location = location;
                return false;
            });
            $('.ebcms-overflow').each(function(index, el) {
                $(this).width($(this).parent().width()-10);
            });
            $('.ebcms-overflow').bind('dblclick', function(event) {
                if ($(this).width() < 200) {
                    var maxwidth = $(window).width()/2;
                    art.dialog({
                        id:'tips',
                        title:'信息预览',
                        lock: false,
                        fixed: false,
                        drag: true,
                    }).content('<div style="max-width:'+maxwidth+'px;">'+$(this).html()+'</div>').show();
                }else{
                    if ($(this).css('overflow') == 'auto') {
                        $(this).css({
                            'overflow': 'hidden',
                            'white-space': 'nowrap'
                        });
                    }else{
                        $(this).css({
                            'overflow': 'auto',
                            'white-space': 'normal'
                        });
                    }
                }
            });
            $('.ebcms-change').change(function() {
                var $this  = $(this);
                if ($this.attr('confirm')) {
                    EBCMS.MSG.confirm($this.attr('confirm'),function(){
                        $this.data('value', $this.val());
                        EBCMS.CORE.do({
                            url:$this.attr('url'),
                            data:$this.data()
                        });
                    },function(){
                        $this.val($this.data('value'));
                    });
                }else{
                    $this.data('value', $this.val());
                    EBCMS.CORE.do({
                        url:$this.attr('url'),
                        data:$this.data()
                    });
                }
            });
        });
    </script>
</head>
<body>
<div class="col-md-12">
    <h3>
        <span>友情链接</span>
        <a href="<?php echo url('ebcms/config/setting?name=link'); ?>"><span class="glyphicon glyphicon-cog text-muted"></span></a>
        <a href="<?php echo url('add'); ?>"><span class="glyphicon glyphicon-plus text-muted"></span></a>
    </h3>
    <div class="table-responsive">
        <table class="table table-bordered table-hover table-ebcms">
            <tbody>
                <tr>
                    <th style="width:80px;">排序</th>
                    <th>操作</th>
                    <th>名称</th>
                    <th>连接</th>
                </tr>
                <?php 
                    $data = \app\link\model\Link::order('sort desc,id asc') -> select();
                    $data = \ebcms\Tree::group($data);
                 if(is_array($data) || $data instanceof \think\Collection): if( count($data)==0 ) : echo "" ;else: foreach($data as $group=>$items): ?>
                    <tr>
                        <th><?php echo $group; ?></th>
                        <th colspan="3">
                            <a href="<?php echo url('add'); ?>" class="btn btn-primary">添加</a>
                        </th>
                    </tr>
                    <?php if(is_array($items) || $items instanceof \think\Collection): if( count($items)==0 ) : echo "" ;else: foreach($items as $key=>$vo): ?>
                        <tr>
                            <td>
                                <input value="<?php echo $vo['sort']; ?>" class="form-control input-sm ebcms-change" url="<?php echo url('resort'); ?>" data-id="<?php echo $vo['id']; ?>">
                            </td>
                            <td>
                                <?php if(check_auth('status')): switch($vo['status']): case "99": ?>
                                        <button type="button" class="btn btn-danger btn-sm ebcms-do" url="<?php echo url('status'); ?>" data-ids='<?php echo $vo['id']; ?>' data-value='1'>通过</button>
                                        <button type="button" class="btn btn-danger btn-sm ebcms-do" url="<?php echo url('status'); ?>" data-ids='<?php echo $vo['id']; ?>' data-value='0'>屏蔽</button>
                                    <?php break; case "1": ?>
                                        <button type="button" class="btn btn-primary btn-sm ebcms-do" url="<?php echo url('status'); ?>" data-ids='<?php echo $vo['id']; ?>' data-value='0'>已通过</button>
                                    <?php break; default: ?>
                                        <button type="button" class="btn btn-warning btn-sm ebcms-do" url="<?php echo url('status'); ?>" data-ids='<?php echo $vo['id']; ?>' data-value='1'>已屏蔽</button>
                                <?php endswitch; endif; if(check_auth('edit')): ?>
                                <a href="<?php echo url('edit?id='.$vo['id']); ?>" class="btn btn-primary btn-sm">编辑</a>
                                <?php endif; if(check_auth('delete')): ?>
                                    <button type="button" class="btn btn-primary btn-sm ebcms-do" url="<?php echo url('delete'); ?>" data-ids='<?php echo $vo['id']; ?>' confirm="删除后不可恢复，确定删除？">删除</button>
                                <?php endif; ?>
                            </td>
                            <td>
                                <a href="<?php echo $vo['url']; ?>" target="_blank"><?php echo $vo['title']; ?></a>
                            </td>
                            <td><?php echo $vo['url']; ?></td>
                        </tr>
                    <?php endforeach; endif; else: echo "" ;endif; endforeach; endif; else: echo "" ;endif; ?>
            </tbody>
        </table>
    </div>
</div>
</body>
</html>